var a = getApp(), t = void 0;

Page({
    data: {
        account_name: "",
        realname: "",
        account_number: ""
    },
    onLoad: function(a) {
        if ((t = this).setData({
            url: a.url
        }), "update" == a.url) {
            var n = JSON.parse(a.data);
            t.setData({
                url: a.url,
                account_name: n.account_name,
                realname: n.realname,
                account_number: n.account_number,
                id: n.id
            });
        }
    },
    accountInput: function(a) {
        this.setData({
            account_name: a.detail.value
        });
    },
    rnInput: function(a) {
        this.setData({
            realname: a.detail.value
        });
    },
    anInput: function(a) {
        this.setData({
            account_number: a.detail.value
        });
    },
    submit: function() {
        "" == this.data.account_name ? wx.showToast({
            title: "请输入开户行",
            icon: "none"
        }) : "" == this.data.realname ? wx.showToast({
            title: "请输入姓名",
            icon: "none"
        }) : "" == this.data.account_number ? wx.showToast({
            title: "请输入卡号",
            icon: "none"
        }) : (wx.showLoading({
            title: "保存中请稍等",
            mask: !0
        }), a.com.post("wx/account/" + this.data.url, {
            account_name: this.data.account_name,
            realname: this.data.realname,
            account_number: this.data.account_number,
            id: this.data.id || ""
        }, function(a) {
            wx.hideLoading(), 0 === a.errno && (wx.showToast({
                title: "保存成功",
                duration: 1e3
            }), setTimeout(function() {
                wx.navigateBack({
                    delta: 1
                });
            }, 1e3));
        }));
    }
});